package com.huishu.order.controller;


import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.huishu.commons.pojo.Result;
import com.huishu.order.pojo.model.OrderRemarksDO;
import com.huishu.order.service.OrderRemarksService;
import com.huishu.order.utils.AssistantContext;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author generator@ljj
 * @since 2023-07-05
 */
@RestController
@RequestMapping("/order-remarks")
public class OrderRemarksController {

    @Autowired
    private OrderRemarksService orderRemarksService;

    @PostMapping("/add")
    public Result add(@RequestBody OrderRemarksDO orderRemarksDO) {
        orderRemarksDO.setOperator(AssistantContext.currentAdminUser().getName());
        orderRemarksService.save(orderRemarksDO);
        LambdaQueryWrapper<OrderRemarksDO> queryWrapper = Wrappers.lambdaQuery(OrderRemarksDO.class)
                .eq(OrderRemarksDO::getOrderId, orderRemarksDO.getOrderId());
        return Result.success(orderRemarksService.list(queryWrapper));
    }

}
